import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SaleInvoiceVO, SaleInvoiceForm, SaleInvoiceQuery } from '@/api/finance/saleInvoice/types';

/**
 * 查询销售发票列表
 * @param query
 * @returns {*}
 */

export const listSaleInvoice = (query?: SaleInvoiceQuery): AxiosPromise<SaleInvoiceVO[]> => {
  return request({
    url: '/finance/saleInvoice/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询销售发票详细
 * @param id
 */
export const getSaleInvoice = (id: string | number): AxiosPromise<SaleInvoiceVO> => {
  return request({
    url: '/finance/saleInvoice/' + id,
    method: 'get'
  });
};

/**
 * 新增销售发票
 * @param data
 */
export const addSaleInvoice = (data: SaleInvoiceForm) => {
  return request({
    url: '/finance/saleInvoice',
    method: 'post',
    data: data
  });
};

/**
 * 修改销售发票
 * @param data
 */
export const updateSaleInvoice = (data: SaleInvoiceForm) => {
  return request({
    url: '/finance/saleInvoice',
    method: 'put',
    data: data
  });
};

/**
 * 删除销售发票
 * @param id
 */
export const delSaleInvoice = (id: string | number | Array<string | number>) => {
  return request({
    url: '/finance/saleInvoice/' + id,
    method: 'delete'
  });
};
